package com.jht.btconnect.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

public class BTDevicesFragmentPagerAdapter extends FragmentPagerAdapter {

    private List<String> VPTitle = null;
    private List<Fragment> fragmentList = null;

    public BTDevicesFragmentPagerAdapter(@NonNull FragmentManager fm, List<String> VPTitle, List<Fragment> fragmentList) {
        super(fm);
        if (VPTitle == null || fragmentList == null){
            throw new NullPointerException("VPTitle or fragmentList is null !!");
        }
        this.VPTitle = VPTitle;
        this.fragmentList = fragmentList;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return VPTitle.get(position);
    }
}
